home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / Viewperf5.1src.lha / Viewperf5.1 / viewperf / viewperf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-20  |  9.1 KB  |  318 lines

  1. /*
  2. // Permission to use, copy, modify, and distribute this software and its
  3. // documentation for any purpose and without fee is hereby granted, provided
  4. // that the above copyright notice appear in all copies and that both that
  5. // copyright notice and this permission notice appear in supporting
  6. // documentation, and that the name of I.B.M. not be used in advertising
  7. // or publicity pertaining to distribution of the software without specific,
  8. // written prior permission. I.B.M. makes no representations about the
  9. // suitability of this software for any purpose.  It is provided "as is"
  10. // without express or implied warranty.
  11. //
  12. // I.B.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  13. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I.B.M.
  14. // BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  16. // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  17. // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. //
  19. // Author:  Barry Minor, IBM AWS Graphics Systems (Austin)
  20. //          minor@austin.ibm.com
  21. //
  22. // Special Thanks to ..
  23. //
  24. //          John Dennis      of DEC
  25. //          Bob Arenburg     of IBM
  26. //          Rob Putney       of IBM
  27. //          Dale Kirkland    of Intergraph
  28. //          Hock Lee         of Microsoft
  29. //          Tom McReynolds   of SGI
  30. //          John Spitzer     of SGI
  31. //
  32. // and the OPC committee
  33. // for their help in completing this project
  34. */
  35.  
  36. /* Begin Windowing System Dependent */
  37. #ifdef WIN32
  38. #include <stdio.h>
  39. #include <float.h>
  40. #include <windows.h>
  41. #define fprintf print_log
  42. int print_log (FILE *fo, const char *format, ...);
  43. #elif !defined(OS2) && !defined(__amigaos__)
  44. #include <X11/Xlib.h>
  45. #include <GL/glx.h>
  46. #endif
  47. /* End Windowing System Dependent */
  48.  
  49. void startclock (void);
  50. float stopclock (void);
  51. float roundit (float);
  52. char *error2str(GLenum);
  53. #if defined(WIN32)
  54. void APIENTRY FinishFrame(HDC);
  55. #elif defined(OS2) || defined(__amigaos__)
  56. void FinishFrame(void);
  57. #else
  58. void FinishFrame(Display*, GLXDrawable);
  59. #endif
  60.  
  61. #define         VERSION         "5.1"
  62. #define     SCREENX     1280.0
  63. #define     SCREENY     1024.0
  64. #define         X_WINDOW_SIZE   700
  65. #define         Y_WINDOW_SIZE   700
  66. #define         MIN_TEST_TIME   10.0
  67.  
  68. #define         MAXVERTS        40000
  69. #define         MAXPOLYSIDES    100
  70. #define         PI              3.14159265359
  71. #if defined (WIN32) || defined (__hpux) || defined(__amigaos__)
  72. #define         SMALL           FLT_MIN
  73. #define         BIG             FLT_MAX
  74. #else
  75. #define         SMALL           -HUGE
  76. #define         BIG             HUGE 
  77. #endif
  78. #define         ZMIN            0x0
  79. #define         ZMAX            0x7fffff
  80. #define         ZTRANS_SCALE    3.0
  81.  
  82. #define OUTPUT_LEADER "    "
  83. #define OUTPUT_NAME_WIDTH (-51)
  84.  
  85. #undef    MAX
  86. #define MAX(a,b)        ((a)>(b)?(a):(b))  /* return greater of a and b */
  87. #undef    MIN
  88. #define MIN(a,b)        ((a)<(b)?(a):(b))  /* return lesser of a and b */
  89.  
  90. #define ARG_INC  { argv++; argc--; }
  91.  
  92. #define FATAL_ERROR(s)                                                        \
  93. {                                                                             \
  94.   fprintf (stderr, s);                                                        \
  95.   fflush (stderr);                                                            \
  96.   exit (-1);                                                                  \
  97. }
  98.  
  99. #define NOINPUT         0
  100. #define POLYGONINPUT    1
  101. #define MESHINPUT       2
  102. #define TRIINPUT        3
  103. #define QUADINPUT       4
  104.  
  105. #define TMESHmode           0
  106. #define VECTORmode          1
  107. #define LINEmode            2
  108. #define POINTmode           3
  109. #define POLYGONmode         4
  110. #define TFANmode            5
  111. #define TRImode             6
  112. #define QUADmode            7
  113.  
  114. #define BM_NO_BATCH           0
  115. #define BM_BATCH_ALL          1
  116. #define BM_BATCH_BY_TWO       2
  117. #define BM_EXTERNAL             3
  118. #define BM_EXTERNAL_BY_TWO      4
  119.  
  120. #define    NO_NORMmode        0
  121. #define    FACET_NORMmode        1
  122. #define    VERTEX_NORMmode        2
  123.  
  124. #define COLOR_PER_FRAME        0
  125. #define COLOR_PER_PRIMITIVE    1
  126. #define COLOR_PER_VERTEX    2
  127.  
  128. #define VP_TRUE        1
  129. #define VP_FALSE    0 
  130.  
  131. #define TXG_NO_TEX_GEN 0
  132. #define TXG_EYE_LINEAR 1
  133. #define TXG_OBJECT_LINEAR 2
  134. #define TXG_SPHERE_MAP 3
  135.  
  136. #define COLOR3mode    0
  137. #define COLOR4mode    1
  138.  
  139. #define         XPIX    1280
  140. #define         YPIX    1024
  141. #define         NUMPIX  XPIX*YPIX
  142.  
  143. struct plygon
  144. {
  145.         int     numverts;
  146.         int     *index;
  147. };
  148.  
  149. struct vector
  150. {
  151.         GLfloat   x;
  152.         GLfloat   y;
  153.         GLfloat   z;
  154. };
  155.  
  156. struct colorvector
  157. {
  158.         GLfloat   r;
  159.         GLfloat   g;
  160.         GLfloat   b;
  161.         GLfloat   a;
  162. };
  163.  
  164. struct mesh
  165. {
  166.         int                 numverts;
  167.         struct vector       *verts;
  168.         struct vector       *norms;
  169.         struct vector       *texture;
  170.         struct colorvector     *vcolor;
  171. };
  172.  
  173. struct ThreadBlock {
  174.     int            np;
  175.     GLenum            mode;
  176.     GLenum            capability;
  177. #ifdef WIN32
  178.         void (APIENTRY           *ColorP)(const GLfloat *);
  179. #else
  180.         void                    (*ColorP)(const GLfloat *);
  181. #endif
  182.     void            (*externfunc)(GLenum);
  183.         struct vector       *vert;
  184.         struct vector       *vnorm;
  185.         struct vector       *texture;
  186.         struct colorvector       *vcolor;
  187.     int            batchgroups;
  188.     int            batchnum;
  189.     int            batchleftovers;
  190.         struct plygon         *ply;
  191.         struct mesh         *msh;
  192. #ifdef WIN32
  193.     HDC            dc;
  194.     HGLRC            rc;
  195.     DWORD            threadId;
  196.     HANDLE            threadHandle;
  197.     HANDLE            startEvent;
  198.     HANDLE            doneEvent;
  199. #endif
  200. };
  201.  
  202. struct RenderBlock {
  203.         int             np;
  204.         int             numverts;
  205.     GLenum            mode;
  206.     GLenum            capability;
  207. #ifdef WIN32
  208.         void (APIENTRY           *ColorP)(const GLfloat *);
  209. #else
  210.         void                    (*ColorP)(const GLfloat *);
  211. #endif
  212.     void            (*externfunc)(GLenum);
  213.         struct vector       *vert;
  214.         struct vector       *vnorm;
  215.         struct vector       *texture;
  216.         struct colorvector       *vcolor;
  217.         struct plygon         *ply;
  218.         struct mesh         *msh;
  219. };
  220.  
  221. struct EventBlock {
  222.     float            minperiod;
  223.     int            numframes;
  224.     int            doubleBuffer;
  225.     int            clip;
  226.     int            zbuffer;
  227.         int                     walkthruFrame;
  228.     struct vector           *jitter;    /* jitter and redraws are for use with FS antialiasing */
  229.     int                     redraws;
  230.     GLfloat                 blur_frames;
  231.     GLfloat            **walkthru;
  232.     char            *teststring;
  233.     GLfloat            trans[4];
  234.     GLfloat            center[3];
  235. /* Begin Windowing System Dependent */
  236. #ifdef WIN32
  237.         HWND                    window;
  238.         HDC                     display;
  239. #elif !defined(OS2) && !defined(__amigaos__)
  240.     Window            window;
  241.     Display            *display;
  242. #endif
  243. /* End Windowing System Dependent */
  244.     void            (*func)(struct ThreadBlock *);
  245.     struct RenderBlock    *rb;
  246.     int            threads;
  247.     struct ThreadBlock    *tb;
  248. };
  249.  
  250.  
  251. #ifdef LITTLE_ENDIAN
  252. typedef union {
  253.     struct {
  254.         unsigned int Texture:1;        /* 0=OFF 1=ON */
  255.         unsigned int Color:2;          /* 0=FRAME 1=PRIMITIVE 2=VERTEX */
  256.         unsigned int Normal:2;         /* 0=OFF 1=FACET 2=VERTEX */
  257.         unsigned int RenderMode:3;     /* 0=NO_BATCH 1=BATCH_ALL 2=BATCH_BY_TWO */
  258.                                        /* 3=EXTERNAL 4=EXTERNAL_BY_TWO - no batching */
  259.  
  260. #ifdef FUNCTION_CALLS
  261.         unsigned int ColorVectorLength:1; /* 0=glColor3fv   1=glColor4fv  */
  262. #endif
  263.     unsigned int BlurMode:1;       /* 0 = no motion blur.  1= motion blur */
  264.     unsigned int FSAA:1;           /* 0 = no full scene antialiasing, 1 = some */
  265. #ifdef FUNCTION_CALLS
  266.         unsigned int Pad:21;           /* pad bits to fill word */
  267. #else
  268.         unsigned int Pad:22;           /* pad bits to fill word */
  269. #endif
  270.     } bits;
  271.     unsigned int word;
  272. } RenderIndex;
  273.  
  274. typedef union {
  275.     struct {
  276.         unsigned int DisplayList:1;    /* 0=OFF 1=ON */
  277.     unsigned int BlurMode:1;       /* 0=OFF 1=ON */
  278.     unsigned int FSAA:1;           /* Full scene antialiasing on/off */
  279.     unsigned int Walkthru:1;       /* Walkthru mode */
  280.         unsigned int Pad:28;           /* pad bits to fill word */
  281.     } bits;
  282.     unsigned int word;
  283. } EventLoopIndex;
  284. #else
  285. typedef union {
  286.     struct {
  287. #ifdef FUNCTION_CALLS
  288.         unsigned int Pad:21;           /* pad bits to fill word */
  289. #else
  290.         unsigned int Pad:22;           /* pad bits to fill word */
  291. #endif
  292.     unsigned int FSAA:1;           /* Full scene antialiasing */
  293.     unsigned int BlurMode:1;       /* 0 = no motion blur, 1 = mb */
  294. #ifdef FUNCTION_CALLS
  295.         unsigned int ColorVectorLength:1; /* 0=glColor3fv   1=glColor4fv  */
  296. #endif
  297.         unsigned int RenderMode:3;     /* 0=NO_BATCH 1=BATCH_ALL 2=BATCH_BY_TWO */
  298.                                        /* 3=EXTERNAL 4=EXTERNAL_BY_TWO - no batching */
  299.         unsigned int Normal:2;         /* 0=OFF 1=FACET 2=VERTEX */
  300.         unsigned int Color:2;          /* 0=FRAME 1=PRIMITIVE 2=VERTEX */
  301.         unsigned int Texture:1;        /* 0=OFF 1=ON */
  302.     } bits;
  303.     unsigned int word;
  304. } RenderIndex;
  305.  
  306. typedef union {
  307.     struct {
  308.         unsigned int Pad:28;           /* pad bits to fill word */
  309.     unsigned int Walkthru:1;       /* Walkthru mode */
  310.     unsigned int FSAA:1;           /* Full scene antialiasing */
  311.     unsigned int BlurMode:1;       /* motion blur */
  312.         unsigned int DisplayList:1;    /* 0=OFF 1=ON */
  313.     } bits;
  314.     unsigned int word;
  315. } EventLoopIndex;
  316.  
  317. #endif
  318.